package com.itheima.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import com.itheima.pojo.Attendance;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDate;
import java.util.Date;
import java.util.List;

@Mapper
public interface AttendanceMapper extends BaseMapper<Attendance> {

    List<Attendance> selectByMemberIdAndDateBetween(Long memberId, LocalDate startDate, LocalDate endDate);

    @Select("SELECT attendance.*, u.nickname FROM attendance " +
            "LEFT JOIN user u ON attendance.member_id = u.id " +
            "WHERE attendance.member_id = #{userId}")
    List<Attendance> selectAttendanceWithNickname(@Param("userId") Integer userId);

}
